home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (C) 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- #include <stdio.h>
- #include <malloc.h>
- #include <string.h>
- #include "HelpDialog.h"
-
- #include <Xm/Text.h>
- #include <Xm/LabelG.h>
- #include <Xm/List.h>
- #include <Xm/Form.h>
-
- static int count;
- static Arg args[10];
-
- static char *helpText = "\
- OVERVIEW\n\
- ========\n\
- \n\
- VCal is a simple calendar program with alarms. You can make entries\n\
- that are either single instance or repeating, and have alarm events.\n\
- \n\
- Current Features:\n\
- \n\
- Appointments can have multiple alarm events, and alarm events can\n\
- popup a dialog, send email, and/or execute a commmand.\n\
- \n\
- Month and week overview displays.\n\
- \n\
- Month PostScript printing, day/week/month ASCII output.\n\
- \n\
- Multi-line text appointments.\n\
- \n\
- Full control of configurable options through preferences dialog.\n\
- \n\
- Support for multiple, simultaneous accessors of the same database.\n\
- \n\
- Current Limitations:\n\
- \n\
- Modifications to repeating entries affect all instances.\n\
- \n\
- The -daily, -weekly, -monthly, and -printMonth switches still require\n\
- an X connection.\n\
- \n\
- Alarm advance warnings not specified in days do not work across day\n\
- boundaries.\n\
- \n\
- Alarms scheduled to fire on a previous day will trigger at 12am on the\n\
- the previous day if VCal is running, or at startup when VCal is started\n\
- on the previous day.\n\
- \n\
- You cannot delete an alarm's entry from the popup dialog if the entry\n\
- is for a future day (i.e. the advance notice is measured in days).\n\
- \n\
- \n\
- MONTH VIEW\n\
- ==========\n\
- \n\
- The main window of VCal shows a single month. Today, if visible, is\n\
- highlighted. Clicking on a day changes the Day View to show the\n\
- entries for that day. The Day View will be created as necessary.\n\
- If you hold down the Shift key while clicking on a day, the Week\n\
- Overview will be displayed instead.\n\
- \n\
- By default, a menubar is displayed in the Month View. For a cleaner\n\
- appearance, users may want to hide the menubar using the Preferences\n\
- item under the File menu. If you hide the menubar, you can still\n\
- access the menu items by right-clicking in the header area, to bring\n\
- up a popup menu with the same contents.\n\
- \n\
- Left-click in the header to move to the current month. The left and\n\
- right arrows will decrement and increment the month, respectively.\n\
- \n\
- \n\
- DAY VIEW\n\
- ========\n\
- \n\
- The day view shows the entries for a single day. By default, it only\n\
- shows the time range from 8am to 7pm. A dotted line shows the current\n\
- time, if today is being viewed. Change the Restricted toggle under the File\n\
- menu to alternate between restricted and 24-hour display.\n\
- \n\
- To create a new entry, left click to the right of the start time.\n\
- This will create a blank entry. Enter the text for the entry,\n\
- pressing Return twice at the end to finalize it. You can also\n\
- finalize the entry by left-clicking in the time area.\n\
- \n\
- Once you have created an entry, you can left-click on it to make it\n\
- editable again. While you are editing an entry, grab areas will\n\
- appear in the lower-left and upper-right. Use the left-button to\n\
- resize that corner (e.g. adjust the entry length), and the\n\
- right-button to move the entry (e.g. change the start time). As you\n\
- make these adjustments, the time range for the entry will be displayed\n\
- to the left of the entry text.\n\
- \n\
- If you right-button in the entry, a popup menu will appear. Select\n\
- Entry Attributes to examine and modify the entry-specific\n\
- parameters. Select Delete Entry to remove that entry. Erasing all\n\
- the text will also remove an entry.\n\
- \n\
- Left-click in the header to move to the current day. The left and\n\
- right arrows will decrement and increment the day, respectively.\n\
- \n\
- \n\
- ENTRY ATTRIBUTES\n\
- ================\n\
- \n\
- Each entry has certain attributes associated with it, as well as the\n\
- entry text.\n\
- \n\
- Entry Kind Single instance, or some form of repeating. Beware\n\
- that changes or deletion of repeating entries affect\n\
- all of the repeating instances. There is currently\n\
- no support for changing or deleting only a single\n\
- instance of a repeating entry.\n\
- \n\
- Annotate Day This entry should cause this day to be colored in\n\
- the Month View if the Annotate Month View\n\
- preference is set.\n\
- \n\
- Notification Popup This entry causes an alarm dialog to post, if\n\
- the Use Alarm Notifications prefence is set.\n\
- \n\
- Notification Bell This entry beeps the display, if\n\
- the Use Alarm Notifications prefence is set.\n\
- \n\
- Notification Mail This entry sends mail to the user, if\n\
- the Use Alarm Notifications prefence is set.\n\
- \n\
- Notification Command This entry executes a command, if\n\
- the Use Alarm Notifications prefence is set.\n\
- \n\
- Alarm Advance Notices The delay(s) before the entry start when an alarm\n\
- is posted, if the Use Alarm Notifications preference\n\
- is set. The default value is the Default Advance\n\
- Notice preference. Separate multiple advance\n\
- notices with commas, and specify units (min, hour,\n\
- or day). The default unit is minutes.\n\
- \n\
- Repeat End Date If this entry kind is repeating, the date to stop\n\
- repeating. No repeat end date indicates that\n\
- the entry should repeat forever.\n\
- \n\
- \n\
- MONTH OVERVIEW\n\
- ==============\n\
- \n\
- The Month Overview is read-only, but you can click on a particular day\n\
- and have the Day View display that day's entries. Use the navigation\n\
- arrows in the Month View to change the month displayed in the Month\n\
- Overview. Change the Restricted toggle under the File menu to alternate\n\
- between restricted and 24-hour entry markers.\n\
- \n\
- \n\
- WEEK OVERVIEW\n\
- =============\n\
- \n\
- The Week Overview is read-only, but you can click on a entry and have\n\
- the Day View display that entry's day and time. Use the navigation\n\
- arrows in the Day View or select a day in the Month View to change the\n\
- week displayed in the Week Overview. Change the Restricted toggle under the\n\
- File menu to alternate between restricted and 24-hour display.\n\
- \n\
- \n\
- PREFERENCES\n\
- ===========\n\
- \n\
- VCal comes with a standard set of parameters that should be useful to\n\
- most users. However, some users may want to customize VCal for their\n\
- own situation. Use the Preferences item in the File menu of the Month\n\
- View to bring up the preferences dialog.\n\
- \n\
- Because of the complexity of all the preferences, the Revert To\n\
- Factory Preferences item in the File menu of the Month View will\n\
- change all but one preference back to the factory (default) settings.\n\
- The only preference not changed is Hide Menu Bar, Use Popup.\n\
- \n\
- The preferences are separated into four groups:\n\
- \n\
- Configuration\n\
- \n\
- Hide Menu Bar, Use Popup Don't display a menubar in Month View. [off]\n\
- \n\
- Show Time In Icon Display the current time in the iconname,\n\
- for those who want a clock there. This\n\
- prevents the screen saver from activating\n\
- in some SGI X displays. [off]\n\
- \n\
- Show Date In Icon Display the current date in the iconname.\n\
- [off]\n\
- \n\
- Annotate Month View Days with annotated-entries are colored. [on]\n\
- \n\
- Show Late Appointments When VCal is started, post alarms for\n\
- today's entries that have already happened.\n\
- [off]\n\
- \n\
- Use 24-Hour Time Format Display times in 24-hour format. [off]\n\
- \n\
- Snooze Time When an alarm is posted and the user selects\n\
- Snooze, the number of minutes before the\n\
- alarm fires again. [2]\n\
- \n\
- Update Interval Number of seconds between VCal time updates,\n\
- database checks for alarms, and file\n\
- modification checks for other writers. [60]\n\
- \n\
- \n\
- Alarm\n\
- \n\
- Use Alarm Notifications For alarming entries, whether to trigger\n\
- alarms. Some users may want to suspend\n\
- alarms temporarily. Users who are examining\n\
- someone else's database and who don't want\n\
- alarms should set the *displayAlarms\n\
- resource to False instead of changing this\n\
- preference option, since doing so will\n\
- affect all readers of the database. [on]\n\
- \n\
- Annotate Day By Default The default setting of the Annotate Day\n\
- entry attribute. [on]\n\
- \n\
- Notification Popup Popup a dialog for an alarm. [on]\n\
- \n\
- Notification Bell Beep for an alarm. [on]\n\
- \n\
- Confirm Popup Delete Post a confirmation dialog before deleting an\n\
- entry with the Delete button in the popup. [on]\n\
- \n\
- Notification Mail Send mail for an alarm. [off]\n\
- \n\
- Notification Command Command to execute for an alarm. For instance,\n\
- one to play a sound file. [null]\n\
- \n\
- Default Advance Notice(s) For alarming entries, trigger alarms at\n\
- these intervals, separated by commas.\n\
- [5 min]\n\
- \n\
- \n\
- Day View\n\
- \n\
- Default Entry Length When a new entry is created, the initial\n\
- length in minutes. [60]\n\
- \n\
- Day View Entry Length The number of minutes between major time\n\
- divisions in Day View. [60]\n\
- \n\
- Number of Day View Subdiv The number of subdivisions between major\n\
- time divisions in Day View. Entry\n\
- start and finish will be restricted to\n\
- this time granularity. [4]\n\
- \n\
- Day View Snap Interval When a new entry is created, it is forced\n\
- to start at one of the time subdivisions\n\
- separated by this number of minutes. [30]\n\
- \n\
- Restrict Day View Instead of displaying the full 24-hours\n\
- of the say, show only a selected range.\n\
- See Restricted Start Hour and Restricted\n\
- Stop Hour. [on]\n\
- \n\
- Restricted Start Hour When Day View is restricted, the first\n\
- hour (in 24-hour format) displayed. [8]\n\
- \n\
- Restricted Stop Hour When Day View is restricted, the first hour\n\
- (in 24-hour format) hidden. The remainder\n\
- of the day is hidden. [9]\n\
- \n\
- \n\
- Database\n\
- \n\
- Calendar Database Filename Where to store the entry information. [~/.vcal]\n\
- \n\
- Annotate File Contents Add comment information to the saved database\n\
- file to reveal the file format. [off]\n\
- \n\
- Automatically Save Changes Save the database file whenever a change is\n\
- made, so the user never has to worry about\n\
- explicitly saving their changes. [on]\n\
- \n\
- \n\
- DATABASE FILES\n\
- ==============\n\
- \n\
- VCal allows multiple readers of the same database file. To specify a\n\
- database file on the command-line, use the -filename option. When\n\
- someone modifies the file, VCal will notice the change and update its\n\
- display. If there are unsaved changes (unlikely, when the\n\
- Automatically Save Changes preference is set), you will be warned and\n\
- asked if you want to flush your changes.\n\
- \n\
- Different preference settings are associated with different database\n\
- files, so individual database owners can maintain their own\n\
- preferences.\n\
- \n\
- \n\
- X RESOURCES\n\
- ===========\n\
- \n\
- All preferences are controlled via the preferences dialog. However,\n\
- there are some useful things to put in your .Xdefaults.\n\
- \n\
- To display the Month View without a window manager titlebar with 4Dwm, add:\n\
- \n\
- 4Dwm*vcal*clientDecoration: -title\n\
- \n\
- To change the color scheme, choose a scheme name from one of the\n\
- subdirectories of /usr/lib/X11/schemes and add something like:\n\
- \n\
- Vcal*scheme: VanGogh\n\
- \n\
- To use a smaller font on non-Indigo/Entry systems, add:\n\
- \n\
- Vcal*useSmallFonts: True\n\
- \n\
- To examine someone else's database and not have alarm events regardless\n\
- of the Use Alarm Notifications setting, add:\n\
- \n\
- Vcal*displayAlarms: False\n\
- \n\
- To change the day annotation color, add something like:\n\
- \n\
- Vcal*annotateColor: red\n\
- \n\
- To automatically place and size the different VCal windows, add\n\
- geometry settings in your .Xdefaults like the following. It is\n\
- important that the character before \"geometry\" be a period and not\n\
- an asterix!\n\
- \n\
- Vcal.geometry: 220x175-195+0\n\
- Vcal*dayView.geometry: +445+155\n\
- Vcal*monthOverview.geometry: 400x390-0+225\n\
- Vcal*weekOverview.geometry: -0-0\n\
- \n\
- \n\
- COMMAND-LINE OPTIONS\n\
- ====================\n\
- \n\
- -file database-file\n\
- This option allows the user to specify a different\n\
- calendar file. The default file is \"~/.vcal\". VCal\n\
- supports multiple accessors of the same file, and\n\
- will update when someone else changes the same file.\n\
- \n\
- -title window-title\n\
- This option specifies the window title used by VCal.\n\
- The default value is \"VCal\".\n\
- \n\
- -iconName icon-name\n\
- This option specifies the icon name used by VCal.\n\
- The default value is \"vcal\".\n\
- \n\
- -scheme color-scheme\n\
- VCal supports color schemes. To select a color\n\
- scheme, choose the name of one of the subdirectories\n\
- under /usr/lib/X11/schemes.\n\
- \n\
- -day date\n\
- This option displays the appointments for the\n\
- specified day to stdout. Use \"today\" to indicate today's date.\n\
- \n\
- -week date\n\
- This option displays the appointments for the\n\
- specified week to stdout. Use \"today\" to indicate today's date.\n\
- \n\
- -month date\n\
- This option displays the appointments for the\n\
- specified month to stdout. Use \"today\" to indicate today's date.\n\
- \n\
- -printMonth date\n\
- This option emits PostScript to stdout, suitable for\n\
- printing the calendar for the month with entries. Use \"today\" to\n\
- indicate today's date.\n\
- \n\
- \n\
- LIMITATIONS\n\
- ===========\n\
- \n\
- Modifications to repeating entries affect all instances.\n\
- \n\
- The -daily, -weekly, -monthly command-line switches still require an X\n\
- connection.\n\
- \n\
- Alarm advance warnings not specified in days do not work across day\n\
- boundaries.\n\
- \n\
- Alarms scheduled to fire on a previous day will trigger at 12am on the\n\
- the previous day if VCal is running, or at startup when VCal is\n\
- started on the previous day.\n\
- \n\
- You cannot delete an alarm's entry from the popup dialog if the entry\n\
- is for a future day (i.e. the advance notice is measured in days).\n\
- \n\
- When printing, do not select the \"Link in spool directory\" option because\n\
- VCal removes the temporary file immediately.\n\
- \n\
- \n\
- COMMENTS\n\
- ========\n\
- \n\
- Motif 1.2 provides drag and drop support when the middle mouse button\n\
- is used. A little \"page\" icon will appear when you click with the\n\
- middle mouse in some areas. Currently, VCal doesn't support drag and\n\
- drop in its interface so there will be little effect.\n\
- \n\
- It is not advised to set the Show Time In Icon preference, since doing\n\
- so may disable the screen saver functionality.\n\
- \n\
- \n\
- POSSIBLE ENHANCEMENTS\n\
- =====================\n\
- \n\
- Ability to modify or delete single instances of repeating entries.\n\
- \n\
- Day PostScript printing.\n\
- \n\
- Merged calendar files for comparison, scheduling, holidays, etc.\n\
- \n\
- Daily note entry.\n\
- \n\
- Enhanced command-line interface.\n\
- \n\
- \n\
- CREDITS\n\
- =======\n\
- \n\
- The PostScript program for printing the month came from Ken Keirnan's\n\
- pcal package, and was originally Copyright (c) 1987 by Patrick Wood\n\
- and Pipeline Associates, Inc. with permission to modify and redistribute.\n\
- \n\
- \n\
- Send bugs, comments, suggestions, and monetary gifts to mikey@sgi.com.\n\
- \n\
- Copyright 1994, Silicon Graphics, Inc. All Rights Reserved.\n\
- \n\
- ";
-
- HelpDialog::HelpDialog(const char *docName)
- : VkSimpleWindow(docName)
- {
- info = NULL;
- numInfo = 0;
- }
-
- HelpDialog::~HelpDialog()
- {
- int each;
-
- if (numInfo) {
- for (each=0; each<numInfo; each++) {
- free(info[each].topic);
- }
- free(info);
- }
- }
-
- const char *
- HelpDialog::className()
- {
- return "HelpDialog";
- }
-
- /**********************************************************************/
-
- void
- HelpDialog::topicSelect(char *topic)
- {
- int each;
-
- for (each=0; each<numInfo; each++) {
- if (!strcasecmp(topic, info[each].topic)) {
- topicSelect(each);
- XmListSelectPos(list, each+1, False);
- break;
- }
- }
- }
-
- /**********************************************************************/
-
- Widget
- HelpDialog::setUpInterface(Widget parent)
- {
- Widget scroll, hs;
-
- count = 0;
- form = XmCreateForm(parent, "form", args, count);
-
- count = 0;
- XtSetArg(args[count], XmNtopAttachment, XmATTACH_FORM); count++;
- XtSetArg(args[count], XmNrightAttachment, XmATTACH_FORM); count++;
- label = XmCreateLabelGadget(form, "label", args, count);
- XtManageChild(label);
-
- count = 0;
- XtSetArg(args[count], XmNselectionPolicy, XmSINGLE_SELECT); count++;
- XtSetArg(args[count], XmNtopAttachment, XmATTACH_WIDGET); count++;
- XtSetArg(args[count], XmNtopWidget, label); count++;
- XtSetArg(args[count], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); count++;
- XtSetArg(args[count], XmNleftWidget, label); count++;
- XtSetArg(args[count], XmNrightAttachment, XmATTACH_FORM); count++;
- XtSetArg(args[count], XmNbottomAttachment, XmATTACH_FORM); count++;
- list = XmCreateScrolledList(form, "list", args, count);
- XtManageChild(list);
- XtAddCallback(list, XmNsingleSelectionCallback,
- HelpDialog::topic_select, (XtPointer) this);
-
- count = 0;
- XtSetArg(args[count], XmNtopAttachment, XmATTACH_FORM); count++;
- XtSetArg(args[count], XmNleftAttachment, XmATTACH_FORM); count++;
- XtSetArg(args[count], XmNbottomAttachment, XmATTACH_FORM); count++;
- XtSetArg(args[count], XmNrightAttachment, XmATTACH_WIDGET); count++;
- XtSetArg(args[count], XmNrightWidget, XtParent(list)); count++;
- text = XmCreateScrolledText(form, "helpText", args, count);
- XtManageChild(text);
-
- displayHelp();
-
- scroll = XtParent(text);
- count = 0;
- XtSetArg(args[count], XmNhorizontalScrollBar, &hs); count++;
- XtGetValues(scroll, args, count);
- if (hs) {
- XtUnmanageChild(hs);
- }
-
- XtManageChild(form);
- return form;
- }
-
- void
- HelpDialog::handleWmDeleteMessage()
- {
- hide();
- }
-
- void
- HelpDialog::displayHelp()
- {
- XmTextSetString(text, helpText);
- createIndex();
- }
-
- void
- HelpDialog::createIndex()
- {
- char *p, *q, *r;
- Boolean first;
-
- first = True;
- p = helpText;
- while (*p != '\0') {
- while (*p != '=' && *p != '\0') {
- p++;
- }
- if (*p != '\0') {
- if (first) {
- q = helpText-1;
- first = False;
- } else {
- q = p;
- while (*q != '\n') {
- q--;
- }
- q--;
- while (*q != '\n') {
- q--;
- }
- }
- r = strchr(q+1, '\n');
- *r = '\0';
- addIndex(q+1, q+1-helpText);
- *r = '\n';
- while (*p == '=') {
- p++;
- }
- }
- }
- }
-
- void
- HelpDialog::addIndex(char *topic, int offset)
- {
- char *p;
- XmString xs;
-
- if (numInfo) {
- info = (HelpIndexInfo *) realloc(info, (numInfo+1)*sizeof(HelpIndexInfo));
- } else {
- info = (HelpIndexInfo *) malloc(sizeof(HelpIndexInfo));
- }
- info[numInfo].topic = strdup(topic);
- p = info[numInfo].topic;
- while (*p != '\0') {
- if (p == info[numInfo].topic || *(p-1) == ' ' || *(p-1) == '-' ||
- *(p-1) == '/') {
- if (*p >= 'a' && *p <= 'z') {
- *p = (*p + 'A' - 'a');
- }
- } else {
- if (*p >= 'A' && *p <= 'Z') {
- *p = (*p + 'a' - 'A');
- }
- }
- p++;
- }
- info[numInfo].offset = offset;
- xs = XmStringCreateSimple(info[numInfo].topic);
- XmListAddItem(list, xs, 0);
- numInfo++;
- }
-
- void
- HelpDialog::topicSelect(int index)
- {
- XmTextSetTopCharacter(text, info[index].offset);
- }
-
- /**********************************************************************/
-
- void
- HelpDialog::topic_select(Widget, XtPointer clientData, XtPointer callData)
- {
- HelpDialog *obj = (HelpDialog *) clientData;
- XmListCallbackStruct *cb = (XmListCallbackStruct *) callData;
-
- obj->topicSelect(cb->item_position-1);
- }
-